package part15;

import java.awt.*;

/**
 * @author wcj
 * @Date 2021/5/30 15:53
 * @Version 1.0
 */
public class Part1523 {

    public static void main(String[] args) {
        Solid<Bound> boundSolid = new Solid<>(new Bound());
        boundSolid.getColor();
        boundSolid.getY();
        boundSolid.weight();
    }
}


interface HasColor {

    /**
     * getColor
     *
     * @return
     */
    java.awt.Color getColor();
}

class Colored<T extends HasColor> {
    T item;

    public Colored(T item) {
        this.item = item;
    }

    T getItem() {
        return item;
    }

    java.awt.Color getColor() {
        return item.getColor();
    }
}

class Dimension {
    public int x, y, z;
}

/**
 * 边界：使用extends 关键字设定边界，并且可以使用&设置多个边界
 * 但是我们可以发现这种方式存在代码的冗余，我们可以使用继承来减少代码的冗余即可
 *
 * @param <T>
 */
class ColoredDimension<T extends Dimension & HasColor> {
    T item;

    public ColoredDimension(T item) {
        this.item = item;
    }

    T getItem() {
        return item;
    }

    java.awt.Color getColor() {
        return item.getColor();
    }

    public int getX() {
        return item.x;
    }

    public int getY() {
        return item.y;
    }

    public int getZ() {
        return item.z;
    }
}

interface Weight {
    /**
     * weight
     *
     * @return
     */
    int weight();
}

class Solid<T extends Dimension & HasColor & Weight> {
    T item;

    Solid(T item) {
        this.item = item;
    }

    T getItem() {
        return item;
    }

    java.awt.Color getColor() {
        return item.getColor();
    }

    public int getX() {
        return item.x;
    }

    public int getY() {
        return item.y;
    }

    public int getZ() {
        return item.z;
    }

    public int weight() {
        return item.weight();
    }
}

class Bound extends Dimension implements HasColor, Weight {

    @Override
    public Color getColor() {
        return null;
    }

    @Override
    public int weight() {
        return 0;
    }
}